package com.cross.hibernate;

import com.cross.cfg.CrossSession;
import com.cross.cfg.CrossSessionFactory;
import com.cross.core.AbstractWriter;

public class PojoWriter<T> extends AbstractWriter {
	private T t;
	private CrossSession<T> crossSession = null;
	
	public PojoWriter() throws Exception{
		CrossSessionFactory crossSessionFactory = CrossSessionFactory.getInstance();
		crossSession = crossSessionFactory.getCrossSession(t.getClass());
	}
	
	public void setCrossSession(CrossSession<T> crossSession){
		this.crossSession = crossSession;
	}
	
	@Override
	protected void writeRow() {
		crossSession.save(currentRow);
	}

	@Override
	public void close() {
		crossSession.close();
	}
}
